<template>
	<view class="cart">
		<scroll-view scroll-y="true" class="cart-it">
			<view class="title">
				<view class="title-it">
					<view>张三</view>
					<view>020-811676888</view>
				</view>
				<view class="title-it2">
					广东省广州市海珠区新港中路397号
				</view>
			</view>
			<!-- 购物车 -->
			<view class="shop">
				购物车
			</view>
			<!-- 购物车列表 -->
			<view class="list" v-for="item,index in list" :key="index">
				<view class="left">
					<image :src="item.img" mode="widthFix" class="cen"></image>
				</view>
				<view class="rig">
					<view class="name">{{item.name}}</view>
					<view class="rig-it">
						<view class="rig-price">
							￥{{item.price*item.num}}
						</view>
						<view class="rig-num">
							x{{item.num}}
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
		<!-- 底部 -->
		<view class="foot">
			<view class="left">

			</view>
			<view class="rig">
				<view class="rig-it1">
					<text>合计:{{getnum}}</text>
					<text class="price"></text>
				</view>
				<button class="mini-btn" type="warn" size="mini" @tap="zhi">支付</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				shop: []
			};
		},
		onLoad() {
			this.list = uni.getStorageSync('shop') || []
			// this.shop = this.list.forEach(item => item.flag)
			// console.log(this.shop);
		},
		computed: {
			getnum() {
				let aa = 0
				this.list.forEach(item => {
					aa += item.price*item.num
				})
				return aa
			}
		},
		methods: {
			zhi() {

			}
		}
	}
</script>

<style lang="scss">
	.foot {
		border: 1rpx solid #ccc;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 10rpx;

		// background: #eb4450;
		.left {
			// width: 45%;
			display: flex;
			align-items: center;
		}

		.rig {
			// width: 55%;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.rig-it1 {
				.price {
					color: red;
				}
			}
		}

	}

	.cart-it {
		height: calc(100vh - 100rpx);
	}

	.list {
		display: flex;
		align-items: center;
		padding: 10rpx;
		margin: 10rpx 0;

		.left {
			width: 40%;
			display: flex;
			align-items: center;

			.cen {
				width: 250rpx;
				margin-left: 10rpx;
			}
		}

		.rig {
			width: 60%;
			margin-left: 20rpx;
			font-size: 30rpx;

			.rig-it {
				margin-top: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.rig-price {
					font-size: 40rpx;
					color: red;
				}
			}
		}
	}

	.cart {
		height: 100vh;

		.title {
			padding: 10rpx;
			// background-color: pink;
			font-size: 35rpx;
			height: 100rpx;

			.title-it {
				display: flex;
				justify-content: space-between;
			}
		}

		.shop {
			border-bottom: 2px solid #f6b8bc;
			border-top: 2px solid #f6b8bc;
			padding: 20rpx;
			color: #eb4450;
		}
	}
</style>
